package com.twu.biblioteca.models;


import java.util.ArrayList;
import java.util.List;

public class MovieDAO {
    private static List<Movie> movies = new ArrayList<Movie>();

    public static final void init(){
        movies.add(new Movie(33, "Como Treinar seu Dragão", 2014, "Dean DeBlois", (byte) 5, false));
        movies.add(new Movie(67, "X-Men: Dias de um Futuro Esquecido", 2014, "Bryan Singer", (byte) 8, false));
        movies.add(new Movie(75, "Capitão América 2 - O Soldado Invernal", 2014, "Anthony Russo", (byte) 10, false));
    }

    public static final List<Movie> getMoviesWithoutCheckout(){
        List<Movie> moviesWithoutCheckout = new ArrayList<Movie>();

        for (Movie movie : movies){
            if(!movie.isCheckout()){
                moviesWithoutCheckout.add(movie);
            }
        }

        return moviesWithoutCheckout;
    }

    public static final Movie getMovie(Long id){
        for (Movie movie : movies){
            if(movie.getId().equals(id)){
                return movie;
            }
        }

        return null;
    }
}
